Methods
(static) makeArrayTransformer(transforms) → {function}
- Source:
- Since:
- 0.1.0
Return a function expecting an array and that applies the provided transforms to its elements
Example
> transformer = makeArrayTransformer([x => x * 20, x => x + 3])
> transformer([2, 2])
[40, 5]
> transformer = makeArrayTransformer([x => x * 20])
> transformer([1, 1, 1, 1, 1])
[20]
> transformer = makeArrayTransformer([x => x * 20, x => x + 3])
> transformer([1])
[20]
Parameters:
Name | Type | Description |
---|---|---|
transforms |
array | array of functions |
Returns:
- Array -> Array
- Type
- function
(static) pluckKeys(keys) → {function}
- Source:
- Since:
- 0.8.0
- See:
Return a function plucking the provided keys from the expected array
Example
> select = pluckKeys(['a', 'k'])
> select([
{a: 1, b: 2, c: 3, k: 4},
{a: 5, b: 8},
])
[{a: 1, k: 4}, {a: 5}]
Parameters:
Name | Type | Description |
---|---|---|
keys |
array | array of keys to pluck |
Returns:
- Array -> Array
- Type
- function
(static) removeAt(indices) → {function}
- Source:
- Since:
- 0.1.0
Return a function expecting an array and removing items at the provided indices
Example
> removeIndices = removeAt([3, 4, 8])
> removeIndices([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
[0, 1, 2, 5, 6, 7, 9]
Parameters:
Name | Type | Description |
---|---|---|
indices |
array |
Returns:
- Array -> Array
- Type
- function